part of '../service.dart';

const _kTrialStartedEventTypeValue = 'trial started';
const _kSubscriptionPurchasedEventTypeValue = 'subscription purchased';
const _kSubscriptionRenewedEventTypeValue = 'subscription renewed';
const _kOneTimePurchaseItemPurchasedEventTypeValue = 'one time purchase item purchased';
const _kTransactionRevokedEventTypeValue = 'transaction revoked';

class _EventTypeDto extends Equatable {
  const _EventTypeDto._internal({
    required this.eventTypeString,
  });

  final String eventTypeString;

  @override
  List<Object?> get props {
    return [
      eventTypeString,
    ];
  }

  factory _EventTypeDto.fromEntity(AmplitudeApiEventType eventType) {
    late final String eventTypeString;

    if (eventType == AmplitudeApiEventType.trialStarted) {
      eventTypeString = _kTrialStartedEventTypeValue;
    } else if (eventType == AmplitudeApiEventType.subscriptionPurchased) {
      eventTypeString = _kSubscriptionPurchasedEventTypeValue;
    } else if (eventType == AmplitudeApiEventType.subscriptionRenewed) {
      eventTypeString = _kSubscriptionRenewedEventTypeValue;
    } else if (eventType == AmplitudeApiEventType.oneTimePurchaseItemPurchased) {
      eventTypeString = _kOneTimePurchaseItemPurchasedEventTypeValue;
    } else if (eventType == AmplitudeApiEventType.transactionRevoked) {
      eventTypeString = _kTransactionRevokedEventTypeValue;
    }

    return _EventTypeDto._internal(
      eventTypeString: eventTypeString,
    );
  }

  @override
  String toString() {
    return eventTypeString;
  }
}
